Skip to content

Fix geoticks for shifted rectangular projections - #829

Merged
cvanelteren merged 1 commit into
mainfrom
fix/geoticks-lon0-828
Sep 28, 2026
Merged

cvanelteren merged 1 commit into
mainfrom
fix/geoticks-lon0-828

Conversation

@cvanelteren

@cvanelteren cvanelteren commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #828.

Cartopy gridliner tick locations are longitude/latitude coordinates, but UltraPlot was assigning them directly to the native Matplotlib x/y axes. That only works when the projection coordinates happen to match geographic coordinates (for example PlateCarree centered at 0°). With a shifted central longitude such as lon0=180, native ticks can be displaced and can expand the axes enough to trigger the pixel-overflow error.

This change explicitly transforms Cartopy geotick locations from PlateCarree into the target projection coordinates, then filters them to the current native x/y limits before installing them with a FixedLocator on the Matplotlib axes. Filtering is important for projections such as Mercator: locator padding can produce near-polar latitude ticks whose projected y values are enormous even though they lie outside the visible map. Passing those ticks through set_ticks() would expand the view limits by design and contaminate the layout bounds; using a FixedLocator avoids that side effect.

Basemap keeps the existing native-axis path.

Regression coverage checks the rectangular Cartopy projections supported by UltraPlot (cyl, merc, lcyl, and mill) for several tick lengths, both global and zoomed extents, and verifies longitude/latitude tick coordinates and successful rendering. It also checks representative non-rectilinear projections (robin, moll, and ortho) to ensure their existing behavior is unchanged: ticklen remains unsupported, emits the existing warning, does not modify native tick locations, and still renders successfully.

@cvanelteren
cvanelteren marked this pull request as draft September 28, 2026 11:24
@cvanelteren cvanelteren self-assigned this Sep 28, 2026
@codecov

codecov Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.71429% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
ultraplot/axes/geo.py 81.25% 1 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@cvanelteren cvanelteren changed the title Fix geoticks for shifted cylindrical projections Fix geoticks for shifted rectangular projections Sep 28, 2026
@cvanelteren
cvanelteren marked this pull request as ready for review September 28, 2026 13:21
@cvanelteren
cvanelteren merged commit 8aaa004 into main Sep 28, 2026
22 checks passed
@cvanelteren
cvanelteren deleted the fix/geoticks-lon0-828 branch September 28, 2026 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ticklen=1 breaks with cyl projection when lon0=180 — pixel overflow error or misaligned ticks

1 participant